package com.qianxx.component.activity.recycleview.pager;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;

import com.qianxx.component.R;
import com.qianxx.component.activity.base.BaseActivity;
import com.qianxx.viewlibrary.recyclerview.pager.HorizontalPageLayoutManager;
import com.qianxx.viewlibrary.recyclerview.pager.PagingScrollHelper;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

public class PagerActivity extends BaseActivity implements PagingScrollHelper.onPageChangeListener {

    @BindView(R.id.rcv)
    RecyclerView rcv;

    PagingScrollHelper scrollHelper;
    Image2Adapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pager);
        ButterKnife.bind(this);

        ArrayList<Integer> images = new ArrayList<>();
        images.add(R.drawable.p1);
        images.add(R.drawable.p2);
        images.add(R.drawable.p3);
        images.add(R.drawable.p4);
        images.add(R.drawable.p5);
        images.add(R.drawable.p6);

        adapter = new Image2Adapter(this);
        rcv.setLayoutManager(new HorizontalPageLayoutManager(1, 1));
        rcv.setAdapter(adapter);
        adapter.setAll(images);

        scrollHelper = new PagingScrollHelper();
        scrollHelper.setUpRecycleView(rcv);
        scrollHelper.setOnPageChangeListener(this);
        scrollHelper.updateLayoutManger();
    }

    @Override
    public String setTitle() {
        return "Pager";
    }

    /**
     * 翻页事件
     *
     * @param index
     */
    @Override
    public void onPageChange(int index) {

    }
}
